<template>
	<view class="flex-col grid-item">
		<view class="flex-col " @click="handleLink(detail.id)">
			<image class="image_4" :src="detail.picture.split(',')[0]" mode="widthFix" />
			<text class="mt-8 font_2">{{detail.title||'--'}}</text>
		</view>
		<view class="mt-6 flex-row justify-between items-center group_5">
			<view class="flex-row items-center">
				<u-image height="32rpx" width="32rpx" shape="circle" :src="detail.avatar.split(',')[0]"
					@click="handleLinkTo(`/page_index/me/components/user-detail/user-detail?id=${detail.publisherId}`)" />
				<text class="ml-6 font_3">{{detail.nickName||'--'}}</text>
			</view>
			<view class="flex-row items-center">
				<u-rate active-icon="heart-fill" inactive-icon="heart" v-model="detail.type==2?1:0" :count="1"
					@change="handleChangeLike"></u-rate>
				<text class="font_4 ml-3">{{detail.likeCount||0}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			data: {
				type: Object
			}
		},
		data() {
			return {
				isLike: 0,
				detail: this.data
			}
		},
		methods: {
			handleChangeLike(value) {
				if (value === 0) {
					this.detail.likeCount--
				} else {
					this.detail.likeCount++
				}
				this.$emit('handleChangeLike', value)
			},
			handleLink(id) {
				this.$emit('linkTo', id)
			},
			handleLinkTo(url) {
				uni.navigateTo({
					url: `${url}`,
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.grid-item {
		background-color: #ffffff;
		border-radius: 16rpx;
		height: max-content;

		.image_4 {
			border-radius: 16rpx 16rpx 0rpx 0rpx;
			width: 100%;
			// height: auto;
		}

		.font_2 {
			margin: 12rpx 16rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			line-height: 28rpx;
			color: #333333;
			display: -webkit-box;
			/* 必须设置此项才能生效 */
			-webkit-line-clamp: 2;
			/* 限制最大行数 */
			-webkit-box-orient: vertical;
			/* 垂直布局 */
			overflow: hidden;
			/* 超出部分隐藏 */
			text-overflow: ellipsis;
			/* 显示省略号 */
		}

		.group_5 {
			padding: 12rpx 16rpx 16rpx 16rpx;

			.font_3 {
				font-size: 20rpx;
				font-family: PingFang SC;
				color: #999999;
				margin-left: 10rpx;
			}

			.image_6 {
				width: 26rpx;
				height: 26rpx;
			}

			.font_4 {
				font-size: 20rpx;
				font-family: PingFang SC;
				color: #999999;
			}
		}
	}
</style>